<p>
<?php

$record = $this->record;

if (isset($this->messages)) {
	foreach ($this->messages as $field => $messages) {
		foreach ($messages as $message) {
			echo $this->escape($message) . "<br />\n";
		}
	}	
}

if (isset($_POST['btnSave'])) {
	foreach($_POST as $key=>$item) {
		$record[$key] = $item;
	}
}
?>
<a href="<?php echo $this->baseUrl; ?>/admin/user">Lists</a> |
<a href="<?php echo $this->baseUrl; ?>/admin/user/add">Add</a> |
<a href="<?php echo $this->baseUrl; ?>/admin/user/delete<?php echo (isset($record['id']) && $record['id'])? "/id/{$record['id']}" : ""; ?>">Delete</a>
<form action="<?php echo $this->baseUrl ?>/admin/user/edit<?php echo (isset($record['id']) && $record['id'])? "/id/{$record['id']}" : ""; ?>" method="POST">
<table cellpadding="2" cellspacing="2">
	<tr>
		<td align="right">Id:</td>
		<td><em>
			<?php
			echo (isset($record['id']) && $record['id'])? $record['id'] : 'Autogenerated'; 
			?></em>
		</td>
	</tr>
	<tr>
		<td align="right">Username:</td>
		<td><?php echo $record['username']; ?></td>
	</tr>
	<tr>
		<td align="right">*Role:</td>
		<td>
			<select name="role_id">
			<?php
			if ($this->roles) {
				foreach ($this->roles as $role) {
					echo "<option value=\"{$role['id']}\"";
					if ($record['role_id'] == $role['id']) {
						echo " selected=\"selected\"";
					}
					echo ">{$role['name']}</option>";
				}
			}
			?>
			</select>
		</td>
	</tr>
	<tr>
		<td align="right">*Last Name:</td>
		<td><input name="last_name" type="text" value="<?php echo $record['last_name']; ?>" /></td>
	</tr>
	<tr>
		<td align="right">*First Name:</td>
		<td><input name="first_name" type="text" value="<?php echo $record['first_name']; ?>" /></td>
	</tr>
	<tr>
		<td align="right">*Middle Name:</td>
		<td><input name="middle_name" type="text" value="<?php echo $record['middle_name']; ?>" /></td>
	</tr>
	<tr>
		<td align="right">Website:</td>
		<td><input name="website" type="text" value="<?php echo $record['website']; ?>" /></td>
	</tr>
	<tr>
		<td align="right">*Email:</td>
		<td><input name="email" type="text" value="<?php echo $record['email']; ?>" /></td>
	</tr>
	<tr>
		<td align="right">Phone:</td>
		<td><input name="phone" type="text" value="<?php echo $record['phone']; ?>" /></td>
	</tr>
	<tr>
		<td align="right">Mobile:</td>
		<td><input name="mobile" type="text" value="<?php echo $record['mobile']; ?>" /></td>
	</tr>
	<tr>
		<td align="right">Address:</td>
		<td><input name="address" type="text" value="<?php echo $record['address']; ?>" /></td>
	</tr>
	<tr>
		<td align="right">&nbsp;</td>
		<td>
			<input type="submit" name="btnSave" value="Save">
			<input type="submit" name="btnCancel" value="Cancel">
		</td>
	</tr>
</table>
</form>
</p>